/**
 * 管理员请求
 * @author 康文程
 * @date 2024-1-10 下午 07:04
 */
class Administrator {
    /**
     * 登陆
     * @param id
     * @param password
     * @return {Promise<unknown>}
     */
    judgementMenu(id,password) {
        return new Promise((resolve, reject) => {
            $.ajax({
                url: "/www.xiaomi.com/background/account",
                method: "GET",
                data: {
                    id: id,
                    password:password
                },
                success: function (response) {
                    resolve(response);
                },
                error: function (error) {
                    reject(error);
                }
            });
        });
    }

    /**
     * 退出登陆
     * @return {Promise<unknown>}
     */
    logOut(){
        return new Promise((resolve, reject) => {
            $.ajax({
                url: "/www.xiaomi.com/background/log/out",
                method: "GET",
                success: function (response) {
                    resolve(response);
                },
                error: function (error) {
                    reject(error);
                }
            });
        })
    }

    /**
     * 新增账号
     * @param administrator json实体类
     * @return {Promise<unknown>}
     */
    addAdministrator(administrator){
        return new Promise((resolve, reject) => {
            $.ajax({
                url: "/www.xiaomi.com/background/add/administrator",
                method: "POST",
                data: {
                    administrator:JSON.stringify(administrator)
                },
                success: function (response) {
                    resolve(response);
                },
                error: function (error) {
                    reject(error);
                }
            });
        });
    }

    /**
     * 查询账号
     * @param administratorId json实体类
     * @return {Promise<unknown>}
     */
    getAdministratorId(administratorId){
        return new Promise((resolve, reject) => {
            $.ajax({
                url: "/www.xiaomi.com/background/get/administrator",
                method: "GET",
                success: function (response) {
                    resolve(response);
                },
                error: function (error) {
                    reject(error);
                }
            });
        });
    }

    /**
     * 删除拥有权限
     * @param permissions 消息Id
     * @return {Promise<unknown>}
     */
    deleteAdministrator(permissions){
        return new Promise((resolve, reject) => {
            $.ajax({
                url: "/www.xiaomi.com/background/delete/activity",
                method: "POST",
                data: {
                    permissions:permissions
                },
                success: function (response) {
                    resolve(response);
                },
                error: function (error) {
                    reject(error);
                }
            });
        });
    }
}